Skip to content

Handle read-only queries with informational responses#65

Merged
jeffgreendesign merged 4 commits intomainfrom
claude/fix-dashboard-query-error-oqtN0
Apr 5, 2026
Merged

Handle read-only queries with informational responses#65
jeffgreendesign merged 4 commits intomainfrom
claude/fix-dashboard-query-error-oqtN0

Conversation

@jeffgreendesign
Copy link
Copy Markdown
Owner

Summary

This PR adds support for handling read-only queries and informational responses from the orchestrator. When a user asks a simple question that doesn't require any operations (e.g., "What's the current price?"), the system now displays the response text and suggestions instead of erroring out.

Key Changes

  • Schema updates: Modified OrchestratorResponseSchema to allow changeSet to be nullable and added optional suggestions array field
  • Response handling: Updated both submitIntent and submitIntentForProduct to detect when the orchestrator returns no operations and treat it as an informational response rather than an error
  • State management: Added infoResponse state to store reasoning, readerText, and suggestions from read-only queries, plus dismissInfo callback to clear it
  • UI improvements:
    • Intent bar now displays informational responses in a dedicated card with reasoning, optional reader text, and clickable suggestion buttons
    • Input field remains enabled when viewing an informational response, allowing follow-up questions
    • Added "Dismiss" button to clear the informational response and return to idle state
    • Updated placeholder text to guide users when viewing an informational response
  • Phase management: Changed phase to "complete" (instead of "error") when receiving informational responses, allowing the UI to distinguish between successful operations and read-only queries

Implementation Details

  • The detection logic checks if changeSet is null or has zero operations, treating both cases as informational responses
  • Suggestions are rendered as interactive buttons that populate the input field and dismiss the info response
  • The informational response card uses muted styling to differentiate it from error states
  • All error state clearing (setInfoResponse(null)) is properly integrated into existing cleanup flows

https://claude.ai/code/session_01MdvMfftU9ACHPEvmrwQrs4

@vercel
Copy link
Copy Markdown

vercel Bot commented Apr 5, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
commerce-changeset Ready Ready Preview, Comment Apr 5, 2026 6:50pm

Request Review

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 5, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 235cb25b-8bfb-446b-a7dd-fa5eb2c14175

📥 Commits

Reviewing files that changed from the base of the PR and between 2313432 and 86a27f6.

📒 Files selected for processing (3)
  • CHANGELOG.md
  • components/workspace/intent-bar.tsx
  • components/workspace/workspace-provider.tsx
✅ Files skipped from review due to trivial changes (1)
  • CHANGELOG.md
🚧 Files skipped from review as they are similar to previous changes (1)
  • components/workspace/intent-bar.tsx

Walkthrough

The changes add a read-only informational response path for intents that produce no workspace changes. The orchestrator response schema now allows a nullable changeSet and optional suggestions. When the orchestrator returns no changeSet (or an empty one), the provider clears any draft changeset, sets infoResponse (with reasoning, optional readerText, optional suggestions), and transitions phase to "complete" instead of treating it as an execution error. submitIntent/submitIntentForProduct clear infoResponse at start; cancelDraft also clears it; dismissInfo() clears infoResponse and sets phase to "idle". IntentBar reads infoResponse to show a read-only panel with reasoning, reader text, and suggestion buttons (suggestions populate the input, call dismissInfo, and refocus); the previous completion banner is shown only when phase === "complete" && !infoResponse. Orchestrator/executor requests now include x-demo-session conditionally when isDemo, and related callbacks updated to include isDemo in deps.

Sequence Diagram

sequenceDiagram
    actor User
    participant IntentBar as IntentBar Component
    participant WorkspaceProvider as WorkspaceProvider
    participant Orchestrator as Orchestrator API

    User->>IntentBar: Enter input & submit
    IntentBar->>WorkspaceProvider: submitIntent(input) (clears infoResponse)
    WorkspaceProvider->>Orchestrator: Send intent request
    Orchestrator-->>WorkspaceProvider: Response (null/empty changeSet + reasoning/suggestions)
    WorkspaceProvider->>WorkspaceProvider: resolveOrchestratorResponse() → set infoResponse, phase="complete"
    WorkspaceProvider-->>IntentBar: Context update (infoResponse)
    IntentBar->>User: Render read-only panel (reasoning, readerText, suggestions)
    User->>IntentBar: Click suggestion
    IntentBar->>WorkspaceProvider: dismissInfo() (also set input to suggestion)
    WorkspaceProvider->>WorkspaceProvider: Clear infoResponse, phase="idle"
    WorkspaceProvider-->>IntentBar: Context update
    IntentBar->>User: Input populated and focused
Loading
🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 66.67% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title 'Handle read-only queries with informational responses' accurately summarizes the main objective of the changeset—adding support for displaying informational responses instead of errors for simple read-only queries.
Description check ✅ Passed The description is comprehensive and directly related to the changeset, clearly explaining the purpose, key changes, UI improvements, and implementation details for handling read-only queries with informational responses.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch claude/fix-dashboard-query-error-oqtN0

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (2)
components/workspace/intent-bar.tsx (1)

145-147: Constrain reader-text panel height to avoid layout push on long responses.

Long readerText payloads can dominate vertical space and bury the input. Consider adding a max height with internal scroll.

🧩 Suggested tweak
-<pre className="mt-2 whitespace-pre-wrap text-xs text-muted-foreground">
+<pre className="mt-2 max-h-56 overflow-auto whitespace-pre-wrap text-xs text-muted-foreground">
   {infoResponse.readerText}
 </pre>
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@components/workspace/intent-bar.tsx` around lines 145 - 147, The readerText
<pre> in intent-bar.tsx can grow arbitrarily and push the layout; constrain its
height and enable internal scrolling by giving the <pre> rendering
infoResponse.readerText a max-height (e.g., via a class or inline style) and
overflow-y: auto so long responses scroll instead of expanding; update the
element that renders infoResponse.readerText (the <pre> with className "mt-2
whitespace-pre-wrap text-xs text-muted-foreground") to include the
maxHeight/overflow styling so the input area is not pushed offscreen.
components/workspace/workspace-provider.tsx (1)

689-701: Extract duplicated informational-response parsing into a shared helper.

The two submit paths now duplicate the same parse/branch/cast flow. Consolidating this will reduce drift risk and make future schema changes safer.

♻️ Suggested direction
+function normalizeOrchestratorResponse(
+  data: z.infer<typeof OrchestratorResponseSchema>,
+): { kind: "info"; info: { reasoning: string; readerText?: string; suggestions?: string[] } }
+ | { kind: "changeset"; changeset: ChangeSet } {
+  const { changeSet: rawCs, reasoning, readerText, suggestions } = data;
+  if (!rawCs || !Array.isArray(rawCs.operations) || rawCs.operations.length === 0) {
+    return { kind: "info", info: { reasoning, readerText, suggestions } };
+  }
+  return { kind: "changeset", changeset: rawCs as unknown as ChangeSet };
+}

Then both submitIntent and submitIntentForProduct can call the same helper.

Also applies to: 750-760

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@components/workspace/workspace-provider.tsx` around lines 689 - 701, The
parsing and informational-response branch (reading validated.data -> {
changeSet: rawCs, reasoning, readerText, suggestions } then checking
rawCs/operations, calling setDraftChangeset/setInfoResponse/setPhase and casting
rawCs to ChangeSet as cs) is duplicated between submitIntent and
submitIntentForProduct; extract this logic into a single helper (e.g.,
parseOrHandleInfoResponse or processValidatedChangeSet) that accepts
validated.data and the setters (setDraftChangeset, setInfoResponse, setPhase)
and returns either a typed ChangeSet or null, preserve the existing runtime
checks (Array.isArray(rawCs.operations) && length > 0) and the unsafe cast
through unknown to ChangeSet, and replace the duplicated blocks in submitIntent
and submitIntentForProduct with calls to that helper.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@CHANGELOG.md`:
- Around line 17-20: There are two "### Fixes" headers under the [Unreleased]
section; remove the duplicate header and move the bullet "- Fix workspace intent
bar erroring on simple questions / read-only queries instead of showing response
text" into the existing "### Fixes" block in the same [Unreleased] section (keep
the exact bullet text and delete the standalone "### Fixes" header). Ensure
there is only one "### Fixes" header under [Unreleased] and preserve surrounding
formatting and spacing.

---

Nitpick comments:
In `@components/workspace/intent-bar.tsx`:
- Around line 145-147: The readerText <pre> in intent-bar.tsx can grow
arbitrarily and push the layout; constrain its height and enable internal
scrolling by giving the <pre> rendering infoResponse.readerText a max-height
(e.g., via a class or inline style) and overflow-y: auto so long responses
scroll instead of expanding; update the element that renders
infoResponse.readerText (the <pre> with className "mt-2 whitespace-pre-wrap
text-xs text-muted-foreground") to include the maxHeight/overflow styling so the
input area is not pushed offscreen.

In `@components/workspace/workspace-provider.tsx`:
- Around line 689-701: The parsing and informational-response branch (reading
validated.data -> { changeSet: rawCs, reasoning, readerText, suggestions } then
checking rawCs/operations, calling setDraftChangeset/setInfoResponse/setPhase
and casting rawCs to ChangeSet as cs) is duplicated between submitIntent and
submitIntentForProduct; extract this logic into a single helper (e.g.,
parseOrHandleInfoResponse or processValidatedChangeSet) that accepts
validated.data and the setters (setDraftChangeset, setInfoResponse, setPhase)
and returns either a typed ChangeSet or null, preserve the existing runtime
checks (Array.isArray(rawCs.operations) && length > 0) and the unsafe cast
through unknown to ChangeSet, and replace the duplicated blocks in submitIntent
and submitIntentForProduct with calls to that helper.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 435749a7-892c-46c3-b9f0-b60c1184ebcb

📥 Commits

Reviewing files that changed from the base of the PR and between 81d7ed1 and 182bad6.

📒 Files selected for processing (3)
  • CHANGELOG.md
  • components/workspace/intent-bar.tsx
  • components/workspace/workspace-provider.tsx

Comment thread CHANGELOG.md Outdated
claude added 4 commits April 5, 2026 18:48
The workspace submitIntent treated all orchestrator responses as action
requests, erroring when no operations were generated. Simple questions
and read-only queries now display reasoning text and suggestions instead
of showing "No operations generated" error.

https://claude.ai/code/session_01MdvMfftU9ACHPEvmrwQrs4
- Fix duplicate ### Fixes header in CHANGELOG.md
- Constrain readerText pre height with max-h-48 overflow-y-auto
- Extract resolveOrchestratorResponse helper to deduplicate submit functions

https://claude.ai/code/session_01MdvMfftU9ACHPEvmrwQrs4
…ches

The workspace submitIntent and executeChangeset calls were missing the
x-demo-session header required by isDemoSession(), causing 401 errors
on the demo dashboard. The reader fetch already included this header.

https://claude.ai/code/session_01MdvMfftU9ACHPEvmrwQrs4
@jeffgreendesign jeffgreendesign force-pushed the claude/fix-dashboard-query-error-oqtN0 branch from 2313432 to 86a27f6 Compare April 5, 2026 18:49
@jeffgreendesign jeffgreendesign merged commit 4bee779 into main Apr 5, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants